package com.nkzy.service.impl;

import com.nkzy.mapper.UserMapper;
import com.nkzy.pojo.User;
import com.nkzy.service.UserService;
import com.nkzy.utils.Md5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 这个 类就是UserService接口的实现类
 * 实现类要完成接口中方法的编写
 * 在实现类中，要通过注解@Service实现Ioc
 *Ioc：控制反转，把创建对象的权力交由Spring框架
 *
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User findUserByName(String username) {
        User user=userMapper.selectUserByName(username);
        return user;
    }

    @Override
    public void register(String username, String password) {
        //1.把密码加密
        String md5String = Md5Util.getMD5String(password);

        //2.注册
        userMapper.insert(username,md5String);


    }
}















































